import { createBrowserRouter,Navigate } from "react-router-dom";
import Layout from "@/pages/SjmLayout/index";
import { lazy } from "react";
import User from "@/pages/user";
import InterviewEvaluation from "@/pages/interviewEvaluation";
import OptionGroup from "@/pages/optionPage/optionGroup";
import SelectOption from "@/pages/optionPage/selectOption";
import Login from "@/pages/login";

// 路由懒加载：使用内置的Suspense组件渲染路由组件
const Candidate =  lazy(() => import('@/pages/candidate'));
const Interview =  lazy(() => import('@/pages/interview'));

const router = createBrowserRouter([
  {
    path: "/",
    Component: Layout,
    children: [
      {
        index: true, // 匹配 "/"
        element: <Navigate to="/candidate" replace />,
      },
      {
        path: "candidate", // 注意这里不需要写 /，已经是子路由了
        element: <Candidate/>,
      },
      {
        path: "interview",
        element: <Interview/>,
      },
      {
        path: "user",
        element: <User/>,
      },
      {
        path: "interviewEvaluation",
        element: <InterviewEvaluation/>,
      },
      {
        path: "optionGroup",
        element: <OptionGroup/>,
      },
      {
        path: "selectOption",
        element: <SelectOption/>,
      },
    ],
  },
  {
    path: "/login",
    element: <Login></Login>,
  }
]);

export default router;